import Vue from 'vue'
import Vuex from 'vuex'
import user from '@/store/modules/user'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        pageLoading: false,
        dataRefresh: false,
        cardMounted: 1,
        allMounted: false,
        cardRender: 1,
        allRender: false
    },
    mutations: {
        setPageLoading (state, payload) {
            state.pageLoading = payload
        },
        setDataRefresh (state, payload) {
            state.dataRefresh = payload
        },
        setCardMounted (state, payload) {
            if (payload) {
                if (state.cardMounted < 9) {
                    ++state.cardMounted
                } else {
                    state.allMounted = true
                }
            } else {
                state.cardRender = 1
                state.allRender = false
                state.cardMounted = 1
                state.allMounted = false
            }
        },
        setCardRender (state, payload) {
            if (payload) {
                if (state.cardRender < 3) {
                    ++state.cardRender
                } else {
                    state.allRender = true
                }
            }
        },
    },
    modules: {
        user
    }
})
